package day10;

import java.io.*;

public class ioPrc02 {
    public static void main(String[] args) {
//        method01();
//        method02();
//        method03();
        method04();
    }

    private static void method01() {
        OutputStream out=null;
        try {
            out=new FileOutputStream("G:\\ready\\5.txt");
            out.write(97);
            out.write(97);
            out.write(97);
            out.write(97);
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method02() {
        BufferedOutputStream out=null;
        try {
            out=new BufferedOutputStream(new FileOutputStream("G:\\ready\\5.txt"));
            out.write(98);
            out.write(98);
            out.write(98);
            out.write(98);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method03() {
        BufferedOutputStream out=null;
        try {
            out=new BufferedOutputStream(new FileOutputStream("G:\\ready\\5.txt"));
            out.write(99);
            out.write(99);
            out.write(99);
            out.write(99);
            out.write(99);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method04() {
        BufferedWriter out=null;
        try {
            out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("G:\\ready\\5.txt")));
            out.write(100);
            out.write(100);
            out.write(100);
            out.write(100);
            out.write(100);
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
